<template>
	<view :class="enrollmentDemand != '' ? 'aaca':'aacb'">
		<view class="" v-if="enrollmentDemand == ''">
			<view class="" style="margin-bottom: 30upx;">
				点击下方按钮，发布招生需求，8年专业的招生老师为你定制招生方案：
			</view>
			<view class="" style="margin-bottom: 30upx;">
				线上/线下招生:
			</view>
			<view class="" style="margin-bottom: 30upx;">
				3-5天精准招生100-1000人
			</view>
			<view class="">
				正价课转化率30%-55%
			</view>
		</view>
		
		<view class="content" v-for="(item,index) in enrollmentDemand" :key="index">
			<view class="">
				<view class="enrollmentdemand-header">
					<view>招生科目：</view>
					<view>{{ item.subjects_name }}</view>
				</view>
				<view class="enrollmentdemand-header">
					<view>招生目标：</view>
					<view>{{ item.needs_num }}人</view>
				</view>
			</view>
			<view style="height: 2upx; background-color: #F2F2F2; margin: 20upx 0upx;"></view>
			<view class="">
				<view class="enrollmentdemand-column">
					<view>发布时间：</view>
					<view>{{ item.create_time | formatDate }}</view>
				</view>
				<view class="enrollmentdemand-column">
					<view>希望招生时间：</view>
					<view>{{ item.needs_time | formatDates }}</view>
				</view>
				<view class="enrollmentdemand-column">
					<view>派单状态：</view>
					<view v-if="item.docking_status" style="color: #1CB45D">正在对接</view>
					<view v-else-if="item.enrollment_status" style="color: #1CB45D">正在招生</view>
					<view v-else :style="item.status ? 'color: #1CB45D' : 'color: #E41D1D;'">{{ item.status?'已发布':'未发布' }}</view>
				</view>
			</view>
			<view style="height: 2upx; background-color: #F2F2F2; margin: 20upx 0upx;"></view>
			<view class="">
				<button type="default" style="color: #FF664F;" class="content-modify-btn" @click="modifyEnrollment(item.id)">修改</button>
			</view>
		</view>
		<button type="default" class="enrollmentdemand-btn" style="color: #ffffff;" @click="releaseEnrollment">发布招生需求</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				// customer_id:'',
				enrollmentDemand: [
					
				]
			}
		},
		onLoad(options){
			// this.customer_id = parseInt(options.customer_id,10)
			this.getEnrollmentDemand()
		},
		onShow() {
			this.getEnrollmentDemand()
		},
		filters: {
			formatDate: function (value) {
			let date = new Date(value * 1000);
			let y = date.getFullYear();
			let MM = date.getMonth() + 1;
			MM = MM < 10 ? ('0' + MM) : MM;
			let d = date.getDate();
			d = d < 10 ? ('0' + d) : d;
			let h = date.getHours();
			h = h < 10 ? ('0' + h) : h;
			let m = date.getMinutes();
			m = m < 10 ? ('0' + m) : m;
			let s = date.getSeconds();
			s = s < 10 ? ('0' + s) : s;
			return y + '-' + MM + '-' + d + ' ' + h + ':' + m + ':' + s;
			},
			formatDates: function (value) {
			let date = new Date(value * 1000);
			let y = date.getFullYear();
			let MM = date.getMonth() + 1;
			MM = MM < 10 ? ('0' + MM) : MM;
			let d = date.getDate();
			d = d < 10 ? ('0' + d) : d;
			return y + '-' + MM + '-' + d;
			}
		},
		methods: {

			// 获取招生需求
			getEnrollmentDemand(){
				console.log("getEnrollmentDemand",this.$store.getters.getToken)
				let data = {
					token:this.$store.getters.getToken,
					customer_id:this.$store.getters.getCustomerId,
					store_id:this.$store.getters.getStoreId,
				}
				console.log("8888888");
				// 3.发送请求
				this.$api.get_enrollmentDemand(data).then(res => {
					console.log(res,"545454");
					if(res.status){
						this.enrollmentDemand = res.data.data
						console.log(this.enrollmentDemand,'招生需求')
					}else{
						uni.showToast({
							title:res.msg,
							icon:'none',
							duration:2000
						})
					}
				}).catch(err =>{
					console.log(err)
				})
			},
			// 发布招生需求
			releaseEnrollment(){
				uni.navigateTo({
					url:"addEnrollmentDemand?topNavActiveIndex=0&customer_id="+this.$store.getters.getCustomerId
				})
			},
			// 修改招生需求
			modifyEnrollment(id){
				uni.navigateTo({
					url:"modifyEnrollmentDemand?topNavActiveIndex=0&customer_id="+this.$store.getters.getCustomerId + "&id=" + id
				})
			}
		}
	}
</script>

<style>
	.content {
		font-size: 28upx;
		width: 628upx;
		padding: 32upx;
		line-height: 50upx;
		background-color: #ffffff;
		border-radius: 16upx;
		margin-bottom: 30upx;
	}
	.enrollmentdemand-header{
		
	}
	.enrollmentdemand-header :nth-child(1){
		display: inline-block; 
		font-size: 32upx; 
		color: #666666;
	}
	.enrollmentdemand-header :nth-child(2){
		display: inline-block; 
		font-size: 32upx; 
		font-weight: bold; 
		color: #333333;
	}
	.enrollmentdemand-column{
		
	}
	.enrollmentdemand-column :nth-child(1){
		display: inline-block;
		color: #666666;
	}
	.enrollmentdemand-column :nth-child(2){
		position: absolute; 
		display: inline-block;
		right: 70upx; 
		color: #666666;
	}
	.content-modify-btn{
		width: 150upx;
		line-height: 50upx;
		font-size: 28upx;
		margin-top: 25upx;
		color: rgba(0,0,0,0.65);
		border-radius: 15upx;
		border: 1upx solid #FF664F;
		color: #FF664F;
		background-color: #ffffff;
		border-radius: 35upx;
	}
	.enrollmentdemand-btn{
		position: fixed;
		bottom: 20upx;
		height: 80upx;
		width: 638upx;
		color: #FFFFFF;
		font-size: 32upx;
		line-height: 80upx;
		text-align: center;
		margin-left: 30upx;
		background-image: linear-gradient(90deg, #FE9543 14%, #FF664F 100%);
		border-radius: 44upx;
	}
	.aaca{
		background-color: #eaeaea; 
		height: 100%; 
		padding: 30upx; 
		padding-bottom: 100upx;
	}
	.aacb{
		background-color: #eaeaea;
		height: 100vh; 
		padding: 30upx; 
		padding-bottom: 100upx;
	}
	button::after{
		border:none;
	}
	/*
	.release-btn{
		width: 400upx;
		line-height: 50upx;
		font-size: 28upx;
		margin-top: 25upx;
		border-radius: 15upx;
		color: #ffffff;
		background-color: #FF8B46;
	}
	.release-btn::after{
		border: none;
	} */
</style>
